{% extends "./layout/layout.html" %}
{% block title %}
<title>网上留言</title>
{% endblock %}

{% block content %}
<div class="sevrmsg1">
  <div class="box wow fadeInUp">
    <!--<div class="nav ">
    您的位置：<a href="service.html">服务支持 / </a> <a href="service_msg.html"> 网上留言 </a>  
  </div>-->
    <div class="tt f_30">网上留言</div>
    <div class="en f_16">ENTRY INFORMATION</div>
    <div class="sbnew">
      （咨询/购买/服务）
    </div>
    <div class="s_tp">
      <ul class="ul1 clearfix">
        <li class="clearfix">
          <div class="llt">咨询类型：<span>*</span></div>
          <select id="inptxtzx">
            <option>业务咨询</option>
            <option>售后服务</option>
            <option>投诉建议</option>
            <option>其他问题咨询</option>
          </select>
        </li>
        <li class="clearfix">
          <div class="llt">设备名称<span>*</span></div>
          <input type="text" id="inptxtmc">
        </li>
        <li class="clearfix">
          <div class="llt">设备使用地<span>*</span></div>
          <input type="text" id="inptxtsy">
        </li>
        <li class="clearfix">
          <div class="llt">单位名称<span>*</span></div>
          <input type="text" id="inptxtdw">
        </li>
        <li class="clearfix">
          <div class="llt">联系人<span>*</span></div>
          <input type="text" id="inptxtlx">
        </li>
        <li class="clearfix">
          <div class="llt">联系电话<span>*</span></div>
          <input type="text" id="inptxtdh">
        </li>
        <li class="clearfix">
          <div class="llt">通信地址<span>*</span></div>
          <input type="text" id="inptxtdz">
        </li>
        <li class="clearfix">
          <div class="llt">邮编<span>*</span></div>
          <input type="text" id="inptxtyb">
        </li>
        <li class="clearfix">
          <div class="llt">国家<span>*</span></div>
          <input type="text" id="inptxtgj">
        </li>

        <li class="clearfix">
          <div class="llt">需求描述<span>*</span></div>
          <textarea id="inptxtxq"></textarea>
        </li>

      </ul>
      <div class="s_yz clearfix">
        <div class="slt clearfix">
          <div class="dlt">验证码<span>*</span></div>
          <input type="text" id="code">
          <img src="https://www.fpi-inc.com/Common/RndCode.aspx" alt="点击更换验证码" id="codeImg"
            onclick="this.src='https://www.fpi-inc.com/Common/RndCode.aspx?rnd=' + Math.random()" />
        </div>
        <span class="f_12">看不清？换一张</span>
      </div>
    </div>

    <div class="abtn clearfix f_12">
      <a id="tj">提 交</a>

    </div>


  </div>
</div>
{% endblock %}


{% block script %}
<script>
  $('.head .abtn .yjdh a').eq(3).addClass('act');

  $('.sevrmsg1 .s_tp .ul1 li').on('click', function () {
    $(this).stop(true, false).addClass('act').siblings().stop(true, false).removeClass('act');
  });

  $('.abtn').click(function () {
    InquiryUP();
  })
  $('#inptxtzx').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtmc').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtsy').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtdw').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtlx').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtdh').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtdz').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtyb').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtgj').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#inptxtxq').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })
  $('#code').bind('keyup', function (event) {
    if (event.keyCode == "13") {
      InquiryUP();
    }
  })

  function InquiryUP() {
    var inp1 = document.getElementById("inptxtzx").value;
    var inp2 = document.getElementById("inptxtmc").value;
    var inp3 = document.getElementById("inptxtsy").value;
    var inp4 = document.getElementById("inptxtdw").value;
    var inp5 = document.getElementById("inptxtlx").value;
    var inp6 = document.getElementById("inptxtdh").value;
    var inp7 = document.getElementById("inptxtdz").value;
    var inp8 = document.getElementById("inptxtyb").value;
    var inp9 = document.getElementById("inptxtgj").value;
    var inp10 = document.getElementById("inptxtxq").value;
    var inp11 = document.getElementById("code").value;
    //if (inp1 == "") {
    //    alert("请填写您的姓名");
    //    return false;
    //}
    if (inp2 == "") {
      alert("请填写设备名称");
      return false;
    }

    if (inp3 == "") {
      alert("请填写使用地");
      return false;
    }
    if (inp4 == "") {
      alert("请填写单位名称");
      return false;
    }
    if (inp5 == "") {
      alert("请填写联系人");
      return false;
    }
    if (inp6 == "") {
      alert("请填写联系电话");
      return false;
    } else if (!codeVerification(inp6)) {
      alert('您的手机号码不正确，请重新填写！');
      return false;
    }
    if (inp7 == "") {
      alert("请填写通信地址");
      return false;
    }
    if (inp8 == "") {
      alert("请填写邮编");
      return false;
    }
    if (inp9 == "") {
      alert("请填写国家");
      return false;
    }
    if (inp10 == "") {
      alert("请填写需求描述");
      return false;
    }
    if (inp11 == "") {
      alert("请填写验证码");
      return false;
    }

    function codeVerification(phone) {
      var phoneCodeVerification = /^[1][3,4,5,7,8][0-9]{9}$/;
      return phoneCodeVerification.test(phone);
    }

    function codeVerification1(phone) {
      var phoneCodeVerification = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
      return phoneCodeVerification.test(phone);
    }

    var formdata = new FormData();
    formdata.append("inp1", inp1)
    formdata.append("inp2", inp2)
    formdata.append("inp3", inp3)
    formdata.append("inp4", inp4)
    formdata.append("inp5", inp5)
    formdata.append("inp6", inp6)
    formdata.append("inp7", inp7)
    formdata.append("inp8", inp8)
    formdata.append("inp9", inp9)
    formdata.append("inp10", inp10)
    formdata.append("inp11", inp11)
    formdata.append("action", "PTInquiry")
    $.ajax({
      url: '/ajax/ajaxup.ashx',
      type: 'post',
      data: formdata,
      async: false,
      contentType: false,
      processData: false,
      success: function (res) {
        res = JSON.parse(res);
        if (res.Msg == 1) {
          alert('信息提交成功。');
          location = 'service_msg.html'
        } else {
          alert('验证码错误。');
        }
      }
    });
  }
</script>
{% endblock %}